#include <iostream>
#include "SqLiteDbWrapper.h"
#include "VehicleStateManager.h"
#include "GpsWrapper.h"

using namespace std;

int GetRouteID();
void InitIO();
void CloseIO();

//htc.cpp - Entry point for program, intialises hardware devices and launches the classes
//responsible for program flow

int main(){

    int routeID;
    //TODO: Read dbPath from a configuration file?
    const char* dbPath = "/home/darabman/Documents/Coding/C++/HTC-ATE-Scratch/Assets/ATE.sqlite";

    InitIO();

    //Main run loop - resets the state machine when a route has been completed
    while(true){
    routeID = GetRouteID();
    SqLiteDbWrapper wrapper(dbPath); //Create the database connection
    VehicleStateManager state(&wrapper, 2); //Launch the State Machine to read vehicle Location
    }

    return 0;
}

int GetRouteID(){   //Reads a hardware property that represents the unique ID for the route -
                    //This signal is replaced by a user choice for testing
    int id = 0;
    while(id < 1 || id > 2){
        cout << "\nEnter Route ID: ";
        cin >> id;
    }
    return id;
}

void InitIO(){      //Makes a series of HTC API calls that initialise the Hardware -
    cout << "Loading Settings from ./config.ini:\n";
    cout << "Setting \'Database Path\' loaded"; cout << "\n";
    cout << "Setting \'GPS Radius\' loaded";cout << "\n";
    cout << "Setting \'Avg Interval\' loaded";cout << "\n";
    cout << "Setting \'Transmit Interval\' loaded";cout << "\n";
    cout << "Setting \'Delay Interval\' loaded";cout << "\n";
    cout << "Setting \'Trend Interval\' loaded";cout << "\n";
    cout << "Setting \'Time Queue Size\' loaded";cout << "\n";
    cout << "Setting \'Avg Queue Size\' loaded";cout << "\n";

    //Initialise
    //*GPS
    //*USB
    //*Odo
    //*Eric
}
